home *** CD-ROM | disk | FTP | other *** search
- Path: user2.mnsinc.com!huang
- From: huang@mnsinc.com (Szu-Wen Huang)
- Newsgroups: comp.lang.c
- Subject: Re: #including everything
- Date: 12 Apr 1996 19:37:53 GMT
- Organization: Monumental Network Systems
- Message-ID: <4kmbei$a2o@news1.mnsinc.com>
- References: <829297481snz@setch.demon.co.uk>
- NNTP-Posting-Host: user2.mnsinc.com
- X-Newsreader: TIN [version 1.2 PL2]
-
- Mark Setchell (Mark@setch.demon.co.uk) wrote:
-
- : I suspect the disadvantages are:
- : 1) If it changes, all files have to be rebuilt - but that's ok it won't
- : change often
-
- If you have an include file that contains all standard library headers,
- the only time that file should change is when the standard library
- changes - not very ;).
-
- : 2) It may bloat the size of the binaries by including unused variables,
- : but that's not really a problem on Virtual Memory machines, and the
- : increase in size isn't much anyway.
-
- The include files contain declarations, not code or data. A respectable
- compiler shouldn't add any code/data size penalty to your program because
- you included an unused header.
-
- : 3) ???
-
- Now for the bomb. Your program can take forever to compile :) as your
- compiler chugs along uselessly through every single standard library
- header. It can somewhat be alleviated if your compiler can do precompiled
- headers, but it's not going to be much. My UX box here has about 2.7MB
- of stuff in /usr/include. Think about compiling all of those for *each*
- source file you have.
-
- : Weighed against this, the advantages are:
- : 1) porting and maintenance become easier with only one file to maintain
-
- If maintenance really bothers you, try a hybrid approach:
-
- #include "mystdio.h" /* in your application code. note the quotes */
-
- and then your local stdio (mystdio.h) might do
-
- #ifdef SGI
- #include <stdio.h>
- ... /* blah di blah
- #endif
-
- This way, you avoid the useless recompilations of headers, and still have
- a relatively easy time maintaining it. Obviously, if you use system-
- specific headers, your local stub header should be smart enough to handle
- the differences.
-
- : 2) all system calls/functions are guaranteed to be prototyped
-
- A respectable compiler should tell you this :)
-
- : 3) ???
-
- : Also, which system files should I #include?
-